package org.dromara.gateway;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.actuate.autoconfigure.jdbc.DataSourceHealthContributorAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.context.metrics.buffering.BufferingApplicationStartup;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * 网关启动程序
 *
 * @author ruoyi
 */
@Slf4j
@SpringBootApplication(exclude = {
        DataSourceAutoConfiguration.class,
        DataSourceHealthContributorAutoConfiguration.class})
public class RuoYiGatewayApplication {
    public static void main(String[] args) {
        // 标记 sentinel 类型为 网关
        /*System.setProperty("csp.sentinel.app.type", "1");
        SpringApplication application = new SpringApplication(RuoYiGatewayApplication.class);
        application.setApplicationStartup(new BufferingApplicationStartup(2048));
        application.run(args);
        System.out.println("(♥◠‿◠)ﾉﾞ  网关启动成功   ლ(´ڡ`ლ)ﾞ  ");*/
        SpringApplication application = new SpringApplication(RuoYiGatewayApplication.class);
        application.setApplicationStartup(new BufferingApplicationStartup(2048));
        ConfigurableApplicationContext context = application.run(args);
        Environment environment = context.getBean(Environment.class);
        System.out.println("(♥◠‿◠)ﾉﾞ  系统模块启动成功   ლ(´ڡ`ლ)ﾞ  ");
        try {
            log.info("\n😉😉😉😉😉😉😉😉😉😉😉😉😉😉😉😉😉😉😉😉😉😉😉😉😉😉😉😉😉😉😉😉😉\n\n\t" +
                    environment.getProperty("spring.application.name") + " 成功运行 ! Access URLs:\n\t" +
                    "内部接口访问：http://127.0.0.1:" + environment.getProperty("server.port") + "\n\t" +
                    "局域网接口访问：http://" + InetAddress.getLocalHost().getHostAddress() + ":" + environment.getProperty("server.port") +
                    "\n😍😍😍😍😍😍😍😍😍😍😍😍😍😍😍😍😍😍😍😍😍😍😍😍😍😍😍😍😍😍😍😍😍\n");
        } catch (UnknownHostException e) {
            log.error("未知错误：{}", e.getMessage(), e);
        }
    }
}
